Skip to content

driver/kubernetes: add manifest-patch driver option#3791

Open
abhay1999 wants to merge 1 commit intodocker:masterfrom
abhay1999:kubernetes-driver-owner-references
Open

driver/kubernetes: add manifest-patch driver option#3791
abhay1999 wants to merge 1 commit intodocker:masterfrom
abhay1999:kubernetes-driver-owner-references

Conversation

@abhay1999
Copy link
Copy Markdown

@abhay1999 abhay1999 commented Apr 9, 2026

Add a generic manifest-patch driver option that accepts a jq
expression applied to the generated Deployment or StatefulSet
manifest after creation.

This allows users to set arbitrary manifest fields not exposed as
dedicated driver options, such as ownerReferences:

docker buildx create \
  --driver kubernetes \
  --driver-opt 'manifest-patch=.metadata.ownerReferences=[{"apiVersion":"actions.github.com/v1alpha1","kind":"EphemeralRunner","name":"runner-xyz","uid":"..."}]'

The jq expression is evaluated using github.com/itchyny/gojq, a
pure-Go jq implementation. The expression is validated at driver
initialization time. An error is returned if the expression is
invalid or produces no output.

Fixes #2626

@abhay1999 abhay1999 force-pushed the kubernetes-driver-owner-references branch from 4fe2a88 to 4fab23b Compare April 13, 2026 03:39
@abhay1999 abhay1999 changed the title driver/kubernetes: add ownerrefs driver option for owner references driver/kubernetes: add manifest-patch driver option Apr 13, 2026
@abhay1999 abhay1999 force-pushed the kubernetes-driver-owner-references branch from 4fab23b to cc6a52e Compare April 13, 2026 03:42
@abhay1999
Copy link
Copy Markdown
Author

@AkihiroSuda I've addressed your feedback and pushed an updated version:

  • Replaced the bespoke ownerrefs option with a generic manifest-patch driver option that accepts any jq expression
  • Used github.com/itchyny/gojq as the jq engine as you suggested
  • The expression is applied to the generated Deployment/StatefulSet after creation by marshaling to JSON, running the jq query, and unmarshaling back
  • DCO is passing, all tests pass
  • Squashed into a single commit and updated the PR description

Example usage for the original ownerReferences use case:

--driver-opt 'manifest-patch=.metadata.ownerReferences=[{"apiVersion":"actions.github.com/v1alpha1","kind":"EphemeralRunner","name":"runner-xyz","uid":"..."}]'

Could you take another look when you get a chance?

@abhay1999 abhay1999 force-pushed the kubernetes-driver-owner-references branch from cc6a52e to cd62112 Compare April 13, 2026 04:16
Add a generic "manifest-patch" driver option that accepts a jq
expression, applied to the generated Deployment or StatefulSet
manifest after creation.

This allows users to set arbitrary manifest fields that are not
exposed as dedicated driver options, such as ownerReferences:

  --driver-opt manifest-patch='.metadata.ownerReferences=[{"apiVersion":"actions.github.com/v1alpha1","kind":"EphemeralRunner","name":"runner-xyz","uid":"..."}]'

The jq expression is evaluated using github.com/itchyny/gojq, a
pure-Go jq implementation. The expression is validated at driver
initialization time, and an error is returned if it is invalid or
produces no output.

Fixes: docker#2626

Signed-off-by: abhay1999 <abhaychaurasiya19@gmail.com>
@abhay1999 abhay1999 force-pushed the kubernetes-driver-owner-references branch from cd62112 to b4c8746 Compare April 13, 2026 05:22
@abhay1999
Copy link
Copy Markdown
Author

Friendly ping — @AkihiroSuda has approved the PR and all review threads are resolved. DCO, lint, and all integration tests are passing. The lint-gopls failures are pre-existing in files unrelated to this PR (builder/, commands/, driver/remote/) and are not caused by our changes (the driver/kubernetes/ package passes go vet cleanly).

Ready to merge whenever convenient. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request - Add Support for Owner References in Kubernetes Driver

3 participants